package xcmg.device.dao.mapper.threeGuaranteesPur;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import xcmg.device.dao.entity.threeGuaranteesPur.ThreeGuaranteesOutDO;
import xcmg.device.service.vo.logistic.BusinessOrderSelectedInfoVO;
import xcmg.device.service.vo.logistic.SelectBusinessBillResultVO;
import xcmg.device.service.vo.logistic.SelectBusinessBillsQueryParamVO;
import xcmg.device.service.vo.threeGuaranteesPur.ThreeGuaranteesOutVO;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface ThreeGuaranteesOutMapper {
    int delete(String id);

    int add(ThreeGuaranteesOutDO record);

    int update(ThreeGuaranteesOutDO record);

    int remove(@Param("ids") List<String> ids);

    ThreeGuaranteesOutDO item(String id);

    List<ThreeGuaranteesOutDO> list(ThreeGuaranteesOutVO model);

    List<ThreeGuaranteesOutDO> findForDeleteByIds(@Param("ids") List<String> ids);

    List<String> findOrderList(@Param("ids") List<String> ids);

    List<ThreeGuaranteesOutDO> findPurchaseNoList(@Param("ids") List<String> ids);

    List<ThreeGuaranteesOutDO> findByIds(@Param("ids") List<String> ids);

    int findCountForExportAll(ThreeGuaranteesOutVO model);

    int updateStatus(@Param("status") int status,@Param("billNo") String billNo);

    ThreeGuaranteesOutDO itemByNo(@Param("billNo") String billNo,@Param("orgId") String orgId);

    /**
     * 获取该公司下所有需要过账的三包出库单
     *
     * @param orgId
     * @return
     */
    List<ThreeGuaranteesOutDO> list4SapPosting(@Param("orgId")String orgId);

    int updateReverseState(@Param("orderList") List<String> orderList, @Param("reverseState") Integer reverseState, @Param("orgId") String orgId);

    int updateReverseSuccessState(@Param("businessOrder") String businessOrder, @Param("reverseState") Integer reverseState, @Param("orgId") String orgId);

    /**
     * 根据三包申请单号和零件号查询对应的sap预留单号
     * @param purchaseNo 三包申请单号
     * @param materialsNo；零件号
     * @return
     */
    List<String> listSapOrderByThreeApply(@Param("purchaseNo")String purchaseNo, @Param("materialsNo")String materialsNo);

    List<ThreeGuaranteesOutDO> listForWJ(ThreeGuaranteesOutVO model);

    List<ThreeGuaranteesOutDO> exportItem(ThreeGuaranteesOutVO condition);

    BigDecimal countOutQty(@Param("materialsNo")String materialsNo, @Param("purchaseNo")String purchaseNo);

    List<ThreeGuaranteesOutDO> selectByPurchaseNo(@Param("purchaseNo") String purchaseNo);

    List<ThreeGuaranteesOutDO> listByCrmOrder(@Param("crmOrder") String crmOrder,@Param("orgId") String orgId);
    /**根据三包申请单号获取出库单*/
    List<ThreeGuaranteesOutDO> findByPurchaseNo(@Param( "purchaseNo" ) String purchaseNo);
    
    List<String> getOutBillNos(@Param( "purchaseNo" ) String purchaseNo);
    //需要排除掉零件已经全部创建了物流运单的数据
    List<SelectBusinessBillResultVO> list4LogisticWaybill(SelectBusinessBillsQueryParamVO filters);
    //指定单据中未被创建物流运单的零件集合，按照单据号+零件号排序
    List<BusinessOrderSelectedInfoVO.Materials> listNotBeLogisticWayMaterials(@Param("businessOrders") List<String> businessOrders);

    ThreeGuaranteesOutDO logisticWayHeadInfo(@Param("guaranteesOutNo") String guaranteesOutNo,@Param("orgId") String orgId);
}
